#include <glf/core/timer.h>
#include <sys/time.h>
#include <time.h>

namespace glf {

int64 GetTicks() {
	// NOTE : Using clock_gettime() instead of gettimeofday() since the latter is considered
	// obsolete since kernel 2.6.18. POSIX.1-2008.
	struct timespec ts;
	clock_gettime(CLOCK_REALTIME, &ts);

	// Return time in micro seconds
	return static_cast<int64> ((double)(ts.tv_sec) * 1000000.0 + (double)ts.tv_nsec / 1000.0);
}

int64 GetTicksPerSecond() {
	// One tick corresponds to one microsecond
	return 1000000;
}

} //namespace glf

